package com.fireandsword.system.controller;

import com.fireandsword.system.annotation.NotControllerResponseAdvice;
import com.fireandsword.system.domain.SysUserInfo;
import com.fireandsword.system.domain.vo.ResultVo;
import com.fireandsword.system.enums.AppCode;
import com.fireandsword.system.exception.APIException;
import com.fireandsword.system.service.ISysUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author Immortal
 * @version 1.0
 * @description TODO
 * @date 2023/12/26 10:31
 */
@RestController
@RequestMapping("/system/user")
public class SysUserInfoController {

    @Autowired
    private ISysUserInfoService sysUserInfoService;


    @GetMapping("/findByName")
    public SysUserInfo getSysUserInfo(@Validated SysUserInfo sysUserInfo) {
        return sysUserInfoService.getSysUserInfo(sysUserInfo.getName());
    }

    @GetMapping("/testString")
    public String getTestString(){
        return "测试返回String类型数据";
    }


    @GetMapping("/special")
    @NotControllerResponseAdvice
    public String getTestSpecial(){
        return "这个是没有被包装过得";
    }

    @GetMapping("/exception")
    public String getTestException(){
        throw new APIException(AppCode.APP_ERROR, "测试抛出业务异常");
    }
}
